export function setCookie(key, value, seconds, path = '/') {
    const date = new Date()
    date.setTime(date.getTime() - 8 * 3600 * 1000 + seconds * 1000)
    document.cookie = `${key}=${value};expires=${date};path=${path}`
}

export function getCookie(key) {
    let cookies = document.cookie
    if (!cookies) {
        return
    }
    cookies = cookies.split('; ')
    for (let a = 0; a < cookies.length; a++) {
        let arr = cookies[a].split('=')
        if (arr[0] === key) {
            return arr[1]
        }
    }
}

export function removeCookie(key, path) {
    setCookie(key, null, -1, path)
}